package com.xyh.service.impl;

import com.xyh.entity.YxcAmount;
import com.xyh.mapper.YxcAmountMapper;
import com.xyh.mapper.YxcCarMapper;
import com.xyh.service.YxcAmountService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class YxcAmountServiceImpl implements YxcAmountService {

    @Resource
    private YxcAmountMapper yxcAmountMapper;

    @Override
    public int addStartAmount(YxcAmount yxcAmount) {
        return yxcAmountMapper.addStartAmount(yxcAmount);
    }

    @Override
    public YxcAmount getAmountByPhone(String login_telephone) {
        return yxcAmountMapper.getAmountByPhone(login_telephone);
    }

    @Override
    public YxcAmount getAmountById(int amount_id) {
        return yxcAmountMapper.getAmountById(amount_id);
    }

    @Override
    public int updateEndAmount(YxcAmount yxcAmount) {
        return yxcAmountMapper.updateEndAmount(yxcAmount);
    }

    @Override
    public List<YxcAmount> getAountByPhoneAndPage(String login_telephone, int current_page, int page_size) {
        String current_pos = String.valueOf((current_page - 1) * page_size);
        String whereCondition = " where 1 = 1 and owner_telephone = " + login_telephone + " and flag = 1 limit " + current_pos + "," + page_size;
        return yxcAmountMapper.getAountByPhoneAndPage(whereCondition);
    }

    @Override
    public YxcAmount getAmountByCarNumber(String car_number) {
        return yxcAmountMapper.getAmountByCarNumber(car_number);
    }

    @Override
    public int deleteByAmountId(int amount_id) {
        return yxcAmountMapper.deleteByAmountId(amount_id);
    }

    @Override
    public int updateEndAmountFree(YxcAmount yxcAmount) {
        return yxcAmountMapper.updateEndAmountFree(yxcAmount);
    }
}
